﻿#ifndef SCHOOLVIEW_H
#define SCHOOLVIEW_H
#include <QGraphicsView>
#include <QLabel>
#include <QMouseEvent>
#include <QMainWindow>
#include <QGraphicsView>
#include <QKeyEvent>
#include "player.h"
#include "math.h"
#include "npc.h"
enum school//初始化的枚举
{
    balitai,jinnan,taida
};
class schoolview : public QGraphicsView
{
    Q_OBJECT
public:
    QTimer *timer;//控制场景的计时器
    void timerEvent(QTimerEvent *) override;//控制视图信息传入和简单处理的计时器

public:
    qreal are=0;
    school it;
    QGraphicsScene *scene;
    npc *o1;
    player *mm;//玩家控制的物体
    player *kg;//自动的物体
    int n=5;//自动物体数目

    bool m_upKeyPressed=false;//bug记录：未初始化
    bool m_downKeyPressed=false;
    bool m_leftKeyPressed=false;
    bool m_rightKeyPressed=false;
    void gameLoop();//对视图信息的简单处理
public slots:
    void slotZoom(int);//缩放地图大小
protected:
    void drawBackground(QPainter *painter, const QRectF &rect); //绘制背景			    								//完成地图显示的功能
    //void mousePressEvent(QMouseEvent *event);
    void keyPressEvent(QKeyEvent *event);//键盘按下
    void keyReleaseEvent(QKeyEvent *event);//键盘释放

private:
    QPixmap map;//背景
    qreal zoom;//缩放
    QLabel *vCoord;//速度显示
    QLabel *xCoord;//坐标显示
    QLabel *mCoord;//分数显示
    double x1,y1;
    double x2,y2;
signals:
    void next();
    void next2();

public:
    QGraphicsLineItem li;
    QPen pen;
    schoolview();
    schoolview(school cho);
    void initialization(school cho);//初始化
    void playGame();//开始游戏
private slots:
    void last();//页面显示
signals:
    void over();
    void back();

};

#endif // SCHOOLVIEW_H
